const app = getApp();
var funcs = require('../../static/js/funcs.js');

Page({

  /**
   * 页面的初始数据
   */
  data: {
    topics:[],
    formRes:[],
    totalTopics: 16,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log("onload触发")
    var params = decodeURIComponent(options.params);
    var data = JSON.parse(params);
    console.log("跳转后收到的值：")
    console.log(data)
    let groupid = data.groupid
    let memberid = data.memberid
    let name = data.name
    let groupname = data.groupname
    let inst = data.inst
    let post = data.post
    let selectdate = data.date
    let that = this
    let openid = app.globalData.openid
    this.setData({
      name:name,
      groupname:groupname,
      inst:inst,
      post:post,
      memberid:memberid,
      selectdate:selectdate
    })

    funcs.getGroupDetail(openid,groupid).then(res=>{
      if(res.data.succeed){
        if(res.data.data.type==1){ // 考核类
          this.setData({
            showtype: 1
          })
          funcs.getKHDetail4Single(openid,groupid,memberid).then(res=>{
            if(res.data.succeed){
              console.log(res.data.data)
              that.setData({
                goodc: res.data.data.goodc,
                okc: res.data.data.okc,
                badc: res.data.data.badc,
                totalc: res.data.data.totail
              })
            }
          })
        }else{
          funcs.getTopicsWithDetail(openid,memberid,groupid,selectdate).then(res=>{
            if(res.data.succeed){
              console.log(res.data.data.topics)
              that.setData({
                topics:res.data.data.topics
              })
            }
          })
        }
      }
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})